---
- import_tasks: psql_setup.yml

# Need to set selinux to permissive for now due to https://bugzilla.redhat.com/show_bug.cgi?id=1291940
- name: switch selinux to permissive
  selinux: policy=targeted state=permissive

- name: install needed packages (yum)
  package: name={{ item }} state=present
  with_items:
  - waiverdb
  - python-gunicorn
  - python-psycopg2
  notify:
  - restart waiverdb
  when: ansible_distribution_major_version|int < 22

- name: install needed packages (dnf)
  dnf: pkg={{ item }} state=present
  with_items:
  - waiverdb
  - python-gunicorn
  - python-psycopg2
  notify:
  - restart waiverdb
  when: ansible_distribution_major_version|int > 21

- name: start waiverdb on boot
  systemd:
    name: waiverdb.socket
    enabled: yes

- name: copy client secrets
  template:
    src: etc/waiverdb/client_secrets.json
    dest: /etc/waiverdb/client_secrets.json
    owner: root
    group: root
    mode: 0640
  notify:
  - restart waiverdb

- name: generate the app config
  template:
    src: etc/waiverdb/settings.py.j2
    dest: /etc/waiverdb/settings.py
    owner: root
    group: root
    mode: 0660
    backup: yes
    force: yes
  notify:
  - restart waiverdb

- name: install the nginx config
  template:
    src: etc/nginx/conf.d/waiverdb.conf.j2
    dest: /etc/nginx/conf.d/waiverdb.conf
    owner: nginx
    group: nginx
    mode: 0640
  notify:
  - restart nginx
 
